package com.travelranking.converter;

import java.util.ArrayList;
import java.util.List;

import com.travelranking.entity.CountryEntity;
import com.travelranking.pojo.Country;

public class CountryConverter {

	public static CountryEntity toEntity(Country pojo) {
		CountryEntity entity = new CountryEntity();
		entity.setId(pojo.getId());
		entity.setName(pojo.getName());
		return entity;
	}

	public static Country toPojo(CountryEntity entity) {
		Country pojo = new Country();
		pojo.setId(entity.getId());
		pojo.setName(entity.getName());
		return pojo;
	}

	public static List<Country> toPojoList(List<CountryEntity> entity) {
		List<Country> result = new ArrayList<Country>();
		if (entity != null) {
			for (CountryEntity e : entity) {
				result.add(toPojo(e));
			}
		}
		return result;
	}
	
}
